Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $to = 'nobody@example.com';
- $subject = 'the subject';
- $message = 'hello';
- $headers = 'From: webmaster@example.com' . "rn" .
- 'Reply-To: webmaster@example.com' . "rn" .
- 'X-Mailer: PHP/' . phpversion();
- mail($to, $subject, $message, $headers);
- ?>
- <?php
- require 'PHPMailerAutoload.php';
- $mail = new PHPMailer;
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'user@example.com'; // SMTP username
- $mail->Password = 'secret'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable encryption, 'ssl' also accepted
- $mail->From = 'from@example.com';
- $mail->FromName = 'Mailer';
- $mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
- $mail->addAddress('ellen@example.com'); // Name is optional
- $mail->addReplyTo('info@example.com', 'Information');
- $mail->addCC('cc@example.com');
- $mail->addBCC('bcc@example.com');
- $mail->WordWrap = 50; // Set word wrap to 50 characters
- $mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
- $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Here is the subject';
- $mail->Body = 'This is the HTML message body <b>in bold!</b>';
- $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
- if(!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- echo 'Message has been sent';
- }
- // multiple recipients
- $to = 'aidan@example.com' . ', '; // note the comma
- $to .= 'wez@example.com';
- // subject
- $subject = 'Birthday Reminders for August';
- // message
- $message = '
- <html>
- <head>
- <title>Birthday Reminders for August</title>
- </head>
- <body>
- <p>Here are the birthdays upcoming in August!</p>
- <table>
- <tr>
- <th>Person</th><th>Day</th><th>Month</th><th>Year</th>
- </tr>
- <tr>
- <td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
- </tr>
- <tr>
- <td>Sally</td><td>17th</td><td>August</td><td>1973</td>
- </tr>
- </table>
- </body>
- </html>
- ';
- // To send HTML mail, the Content-type header must be set
- $headers = 'MIME-Version: 1.0' . "rn";
- $headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
- // Additional headers
- $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "rn";
- $headers .= 'From: Birthday Reminder <birthday@example.com>' . "rn";
- $headers .= 'Cc: birthdayarchive@example.com' . "rn";
- $headers .= 'Bcc: birthdaycheck@example.com' . "rn";
- // Mail it
- mail($to, $subject, $message, $headers);
- <?php
- include('Mail.php');
- $recipients = 'joe@example.com';
- $headers['From'] = 'richard@example.com';
- $headers['To'] = 'joe@example.com';
- $headers['Subject'] = 'Test message';
- $body = 'Test message';
- $smtpinfo["host"] = "smtp.server.com";
- $smtpinfo["port"] = "25";
- $smtpinfo["auth"] = true;
- $smtpinfo["username"] = "smtp_user";
- $smtpinfo["password"] = "smtp_password";
- // Create the mail object using the Mail::factory method
- $mail_object =& Mail::factory("smtp", $smtpinfo);
- $mail_object->send($recipients, $headers, $body);
- ?>
- <?php
- $to = 'SomeOtherEmailAddress@Domain.com';
- $subject = 'This is subject';
- $message = 'This is body of email';
- $from = "From: FirstName LastName <SomeEmailAddress@Domain.com>";
- mail($to,$subject,$message,$from);
- <?php
- $to = "somebody@example.com";
- $subject = "My subject";
- $txt = "Hello world!";
- $headers = "From: webmaster@example.com" . "rn" .
- "CC: somebodyelse@example.com";
- mail($to,$subject,$txt,$headers);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement