Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Yay
    Yay is offline
    Regular Coder Yay's Avatar
    Join Date
    Oct 2008
    Location
    54 North, 1 West
    Posts
    102
    Thanks
    9
    Thanked 1 Time in 1 Post

    Exclamation Send e-mail on button click.

    Hi there,

    I've a new plan. Basically, I now want to send a HTML e-mail to the corresponding person. Here's a brief:

    1. User clicks on a button, sends a HTML e-mail (code below) to the e-mail which would be carried over via the URL by using GET. E-mail output by a left join.
    2. HTML E-mail sends


    How would I accomplish this?

    Any code would be greatly appreciated.

    HTML
    Code:
    <html>
    <body>
    	<style type="text/css">
    	body{
    		text-align: center;
    	}
    	
    	#cert{
    		width: 1648px;
    		height: 821px;
    		margin: 0 auto;
    		background: url('/img/certjpg.jpg');
    		margin-left: -10px;
    		margin-top: -10px;
    		margin-bottom: -10px;
    	}
    	
    	#input{
    		padding-top: 33em;
    		float: left;
    		padding-left: 9em;
    	}
    	.input{
    		width: 900px;
    		height: 80px;
    		background: none;
    		font-family: georgia;
    		color: #fff;
    		font-size: 50px;
    		text-align: center;
    		border: 0;
    	}
    	</style>
    
    <div id="cert">
    
    <div id="input">
    <input type=xt class="input" name="name" value="<?php echo $_GET['name'] ?>" readonly>
    </div>
    
    </div>
    
    </body>
    </html>
    Words and phrases to use when you pretend to know something on CodingForums: Yes. Indeed. Well done. Absolutely Great. Top-notch. Awesome. Cool. Very Good. I see. Oh, yes. I understand. Good.

  • #2
    New Coder
    Join Date
    Jul 2009
    Posts
    37
    Thanks
    1
    Thanked 1 Time in 1 Post
    Thankfully emailing is quite simple in PHP

    PHP Code:
    /**
     * Send an email
     * @param array $recipients Recipients to send to
     * @param string $subject The Email Subject
     * @param string $body - The Email body
     * @param string $headers - Email headers if any
     */
    function sendMail(array $recipients$subject$body$headers null) {
        foreach(
    $recipients as $to) {
            
    mail($to$subject$body$headers);
        }

    Then call using

    PHP Code:
    $subject 'Your Subject';
    $body 'Your Body'
                
    $recipients[] = "Blah@Blah.com";
    $recipients[] = "Blah2@Blah2.com";
                
    // To send HTML mail, the Content-type header must be set
    $headers  'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
                
    sendMail($recipients$subject$body$headers); 
    Done.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •