How send email from PHPMAILER without SMTP - php

Can anyone tell me, how send email from PHPMailer not using SMTP? This class includes the method isMail() and it should send an email using the mail() function instead SMTP. I'm use Xaamp. When I use SMTP server it's not working all.
My code:
$mail=new PHPMailer();
$mail->IsMail();
$mail->From = 'xxxx#email.com';
$body = "Test body message";
$mail->AddAddress("xxxx#emai.com", "John Doe");
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$mail->MsgHTML($body);
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
Send Method returns true and displays message that email has been sent?

The topic is old but for those who will read this.
Try to replace
$mail->isSMTP();
by
$mail->isSendMail();

Related

Unable to send email from godaddy server to godaddy or zoho mail

I am trying to send email from my website to my godaddy mail and zoho mail but its not working.
I tried it on my gmail account and its working fine.
I am using phpmailer.
MY CODE-
require_once "PHPMailerAutoload.php";
//PHPMailer Object
$mail = new PHPMailer;
//From email address and name
$mail->From = "test#deltware.com";
$mail->FromName = "Himanshu Mishra";
$mail->addAddress("my godaddy webmail"); //Recipient name is optional
//Send HTML or Plain Text email
$mail->isHTML(true);
$mail->Subject = "Subject Text";
$mail->Body = "<i>Mail body in HTML</i>";
$mail->AltBody = "This is the plain text version of the email content";
if(!$mail->send())
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
echo "Message has been sent successfully";
}
Please help!!!!!
Your From syntax is wrong
Instead of
$mail->From = "test#deltware.com";
$mail->FromName = "Himanshu Mishra";
It should be
$mail->setFrom('test#deltware.com', 'Himanshu Mishra');
Check this link https://github.com/PHPMailer/PHPMailer

sending attachment fails with php mailer function codeigniter

Here I am trying to send email with an attachment, all codes are running fine but I didn't find any attachment along with the mail, but the same file is getting printed in hyper link that I had given with success message. I have used php mailer class in codeigniter.
public function sendmailto()
{
$this->load->library('phpmail');
$mail = new PHPMailer();
$body = "hello";
$mail->AddReplyTo("reply#mymail.com","First Last");
$mail->SetFrom('noname#mymail.com', 'First Last');
$mail->AddReplyTo("mail#mymail.com","First Last");
$address = "abcd#mymail.com";
$mail->AddAddress($address, "John Doe");
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAttachment("../../uploads/a.pdf"); // attachment
//$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
else {
echo "Message sent!<a href='../../uploads/a.pdf' >click</a>" ;
}
}
I think its path issue you can try this
$attachment = base_url().'/uploads/a.pdf';
$mail->AddAttachment($attachment); // attachment
I think you should change
$mail->MsgHTML();
to
$mail->Body;

Send a file through email after Paypal payment is recieved

Is there any way to send a file in an email upon receiving a Paypal payment? Any tutorials to show how to do this? Any help would be much appreciated.
I would use SwiftMailer / attahching files if I were you upon receiving confirmation from PayPal.
Sending email is easy using the built in mail function in PHP. However, sending attachment is a whole other story.
I'd use a third party library like phpMailer
E.g. sending email with attachment:
require_once('path/to/class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = file_get_contents('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->AddReplyTo("name#yourdomain.com","First Last");
$mail->SetFrom('name#yourdomain.com', 'First Last');
$mail->AddReplyTo("name#yourdomain.com","First Last");
$address = "whoto#otherdomain.com";
$mail->AddAddress($address, "John Doe");
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}

Script php : send mail using phpmailer

I'm trying to send a simple email using phpmailer.
I really have no idea if it's relevant since I'm just doing a php script, but I have apache2 & sendmail, apache2 running and sendmail include in the php.ini (sendmail_path=etc).
So here is my code :
<?php
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = "<h1>Coucou</h1>";
$body = eregi_replace("[\]",'',$body);
$mail->AddReplyTo("totest#test.com","First Last");
$mail->SetFrom('fromtest#test.com', 'First Last');
$mail->AddReplyTo("totest2#test.com","First Last");
$address = "XXXX#gmail.com";
$mail->AddAddress($address, "XXXXX");
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
//$mail->AddAttachment("./test.doc"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
So the thing is that my output is always "Message sent!", even if the script take a really long time to be executed (up to 10minutes !), but the mail never arrived to my mailbox (and I checked the spam folder).
Well I hope someone will have an explanation to that annoying problem!
Thank you anyway.
Regards,
Bdloul

PHPMailer With Attachment Never Received

I am tying to send an email with an attachment using phpmailer.
include_once('/home/site/PHPMailer/class.phpmailer.php');
$mail = new PHPMailer();
$body = $mail->getFile('contents.html');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.free.fr"; // SMTP server
$mail->IsSendmail(); // telling the class to use SendMail transport
$mail->From = "name#sub.fr";
$mail->FromName = "name";
$mail->Subject = "subject";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAddress("sub#sub.net", "name");
$mail->AddAttachment("mylist.csv"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
I receive a "Message sent !" on execution, but no email is ever received.
It is very possible the user you sent the email to did not recieve it due to the fact a lot of mail providers such as AOL and Yahoo block massive amounts of Ip addresses related to email spam. So if the server you are running this php script from is on their blacklist the user will not even receive it to the spam folder.
Check your php email logs.
http://help.yahoo.com/l/us/yahoo/smallbusiness/webhosting/php/php-03.html
Also, if this is not the case, try making sure the file your trying to include exists, and you are passing the correct path to the file. Like #Waygood said, try seeing if it sends without the attachment.

Categories